package com.teamwings.ctrls.formCtrls;

import com.teamwings.common.aspect.annotation.FormControl;
import com.teamwings.common.constant.FormConstant;
import com.teamwings.common.vo.Result;
import com.teamwings.ctrls.FormComponent;
import com.teamwings.modules.design.vo.FormVo;
import com.teamwings.modules.page.service.IPageService;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@FormControl(type = "fw_send")
@Data
public class FwSend extends FormComponent {

    public FwSend() {
        this.type = "fw_send";
    }

    @Override
    public Result<?> trigger(FormConstant.TRIGGER_TYPE type, IPageService pageService,
                           FormVo formDesignCode, Object paramsData) {
        // Map<String, Object> btnParams = (Map<String, Object>)paramsData;
        // 查询绑定
        // if (btnParams.containsKey("getMenuBinding")) {
        //     return this.getMenuBinding(pageService, btnParams);
        // }
        // // 暂时只存在发送功能
        // if (type == FormConstant.TRIGGER_TYPE.CTRL_HANDLER) {
        //     if(this.send(pageService, formDesignCode, paramsData)){
        //         return Result.OK();
        //     } else {
        //         return Result.error("");
        //     }
        // }
        return null;
    }

    // 查询菜单绑定的流程图ID
    // private Result<?> getMenuBinding(IPageService pageService, Map<String, Object> btnParams) {
    //     String sql = "SELECT flow_id, flow_name FROM sys_permission WHERE ";
    //     pageService.executeSql();
    // }

    /**
     * 流程发送
     * @param pageService
     * @param formDesignCode
     * @param paramsData
     */
    private boolean send(IPageService pageService, FormVo formDesignCode, Object paramsData) {
        return true;
    }
}
